//
//  FifthViewController.m
//  UIComprehensive
//
//  Created by lanou3g on 16/1/25.
//  Copyright © 2016年 徐强. All rights reserved.
//

#import "FifthViewController.h"
#import "DataBase.h"
@interface FifthViewController ()

@end

@implementation FifthViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Sqlite数据库";
    //打开数据库
    [[DataBase shareDB] openDB];
    
    //数据库的基本操作：增、删、改、查
    
    //添加数据
    Student *stu = [[Student alloc]init];
    stu.number = 100012;
    stu.name = @"尼古拉斯.文";
    stu.age = 20;
    
    [[DataBase shareDB] addStudent:stu];
    
    // 删除
    //    [[DataBase shareDB] deleteStudentWithNumber:10001];
    // 修改
    Student *s = [[Student alloc]init];
    s.number = 100011;
    s.name = @"尼古拉斯.天";
    s.age = 36;
    [[DataBase shareDB] updateStudent:s];
    
    
    //查询
    NSMutableArray *arr = [[DataBase shareDB] selectAllStudent];
    NSLog(@"%@",arr);
    //关闭数据库
    [[DataBase shareDB] closeDB];
    
}


@end
